<?php
/**
 * Created by PhpStorm.
 * User: 64423
 * Date: 2018/10/31
 * Time: 10:58
 */

namespace app\api\home;


/** 下单操作
 * Class Collect
 * @package app\api\home
 */
class Buy extends Common
{
    // 结算页获取信息
    public function checkout()
    {
        $user_id = input('get.user_id',0);
        $addressId = input('get.addressId',0);  // 选中地址地址
        if($user_id == 0){
            return _json(401, '请先登录',[]);
        }
        // 选中地址信息
        $where = [
            'is_default'=>1
        ];
        if($addressId){
            $where = [
                'id'=>$addressId
            ];
        }

        $checkedAddress = db('address')->where('user_id',$user_id)->where($where)->find();
        $data = [
            'checkedAddress' => $checkedAddress
        ];

        return _json(0, '执行成功',$data);
    }

}